#include <REGX52.H>
#include "Delay.h"
sbit KEY1=P3^1;
sbit KEY2=P3^0;
sbit KEY3=P3^2;
sbit KEY4=P3^3;

char KEY=0;
char KeyNum=0;
unsigned int KEY_S()
{
     
	if(KEY1==0||KEY2==0||KEY3==0||KEY4==0)
	{   Delay(20);
		if(KEY1==0){ KeyNum=1;}
		else if(KEY2==0){ KeyNum=2;}
		else if(KEY3==0){ KeyNum=3;}
		else if(KEY4==0){ KeyNum=4;}
	}
	else
		if(KEY1==0&&KEY2==0&&KEY3==0&&KEY4==0)
		{
		   KeyNum=0;
		}
		
		return KeyNum;
}